package hmis.pos.Common.pojo;

import java.util.List;

public class ApiResponse<T> {
    private int event;        // 返回码
    private String msg;       // 返回信息
    private String token;     // 返回token
    private T obj;            // 单个对象
    private List<T> objList;  // 多个对象

    public ApiResponse() {

    }

    // 构造函数，初始化code和msg
    public ApiResponse(int event, String msg) {
        this.event = event;
        this.msg = msg;
    }

    public ApiResponse(int event, String msg, String token) {
        this.event = event;
        this.msg = msg;
        this.token = token;
    }

    public ApiResponse(int event, String msg, T obj) {
        this.event = event;
        this.msg = msg;
        this.obj = obj;
    }

    public ApiResponse(int event, String msg, List<T> objList) {
        this.event = event;
        this.msg = msg;
        this.objList = objList;
    }

    // 判断结果是否成功
    public boolean isSuccess() {
        return event == 0;
    }

    /**
     * @return the event
     */
    public int getEvent() {
        return event;
    }

    /**
     * @param event the event to set
     */
    public void setEvent(int event) {
        this.event = event;
    }

    /**
     * @return the msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * @param msg the msg to set
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    /**
     * @return the obj
     */
    public T getObj() {
        return obj;
    }

    /**
     * @param obj the obj to set
     */
    public void setObj(T obj) {
        this.obj = obj;
    }

    public List<T> getObjList() {
        return objList;
    }

    public void setObjList(List<T> objList) {
        this.objList = objList;
    }
}
